All right, let's do a little testing to see if we're actually buying our properties and saving them.
And I'm going to do this in Roblox studio and I'm going to use the test server with two players.
See what happens when somebody leaves.
First thing I'm going to do, though, is put some printouts in.
I'm going to go to server script service game manager, and if you go down to the bottom.
Player added event gets fired.
We add our board, we initialize our player data.
Let's look at that.
I'm going to right click.
I'm going to go to Declaration.
It's just above.
You could have scrolled up.
I am going to clear out any data that I might have because I did run the game a few times.
There we go.
Now, when you do that, you're going to get a warning in the output window when you play the game because
this async set async, which clears the data, fires very quickly.
Well, this one fires very quickly after that other one saving data, you're going to get a build up
of two calls.
It'll be fine.
Right.
But it's just warning you saying, hey, it's too quick.
All right.
But that's going to be okay for us.
We're not going to have to worry about that.
And we're going to we're going to re comment this when we're done.
All right.
So here, if we get property, let's go ahead and print that out.
Right.
We want to make sure that when we come back, the second time that property persists.
So maybe let's just take a look at the data itself.
So we'll say data and I'll put a number here.
I'll put one because this is the initialization.
All right, what else are we going to do?
Update player info.
That's fine.
Let's take a look at our saving player data.
That's going to happen every ten seconds and our save loop.
Let's see what's being saved off.
We have our points here.
We should have our property.
Let's do another print and this is going to be two.
And I'll just say data equals data.
And I want one more.
How about when I buy my property?
Right.
So I have my buy script under my lots.
There's my by script.
Right here.
We're going to see if this gets cleared out when we leave.
So we don't need a print statement here.
We actually don't need a print statement here because we're going to see the name on the sign.
So I think the two print statements are good.
Let's go ahead and play our game.
Hit the play button.
See if we can buy a lot.
All right.
Let's take a look at our output window.
And there is the warning for the data store request happening too quickly.
We did two sinks in a row very, very rapidly.
But it's fine.
It cleared it out.
See, we got 10,000 points.
I'm going to buy my property.
Nice.
Simtek Nitro.
I can't bring the prompt back up.
That's good.
And then Data two has our points in there, which is down to 5000 and has a property section with a
has lot key value pair has lot equals.
True.
Nice.
Now we're going to leave.
Let's go ahead and stop the game.
Nice.
Let's close this and we've got to go back to our game manager.
And we have to make sure we comment this out or we're going to wipe out everything we just did.
Let's play it again and see if we got a lot.
View output window.
No warning.
Let's see.
That was the data coming in the initialization.
We have a lot here.
Yup.
Has a lot.
Equals true.
And this says Simtek Nitro one.
Yeah.
All right.
Now let's try it in our test manager, our test studio.
Test server.
That's the word I was looking for.
Test server.
All right.
I'm going to close this.
I'm going to start this test server up.
Boom.
Two players.
I'm going to pause the video because it takes a while to start up and we're going to take a look at
what happens when there's two people in the game.
Now, we don't have to worry about the players owning these properties because the user ID is like negative
one and negative two.
If you're using the test server, it's not going to be your regular user ID.
All right, so we got our players in here.
Who am I?
I am.
PLAYER one Let's go over here by a lot.
Notice that I don't own a lot because I am not.
I'm not Simtek Nitro one I'm Player one.
All right, Player one owns the lot.
Let's see if player two goes to buy the lot.
If anything happens.
Nothin.
He can't get it.
What happens when player one leaves the game?
Leave.
I look at that for sale now.
Can we buy this?
We can't.
Oh, yeah, we can.
Oh, good.
I was worried we had an error.
Nice.
Now we both own a property.
I can't play this again or I'll get an error because I only have one lot.
Remember, you have to have as many lots as players who can play the game, but this is fine for testing.
We still have to do our beam and I think I'm going to put a little house on here.
You could buy with like three different sizes, just so you know how to do that.